﻿//AJAX
function sender(target,data,reqmethod,invoketype,callback,t_dom){
	var result = null;
	var reqtype = 'POST';
	if(reqmethod == null){
		reqtype = 'GET';
	}else{
		reqtype = reqmethod;
	}
	var datastr = '';
	if (data != null){
		datastr = JSON.stringify(data);
	}
	var calltype = false;
	if(invoketype != null){
		calltype = invoketype;
	}
	
	$.ajax({
        type: reqtype,
        url: target,
        dataType:"json",
        cache:false,
        async:calltype,
        data: {
            "data":datastr
        },
        success: function(data) {
        	/*if(calltype){      蒋老师之前框架代码  现根据需要修改注释掉
        		//fireUserVerify(callback, data);
        		callback(data,t_dom);//
        	}*/
        	if(data!=null){
        		callback(data,t_dom);
			}else{
        		result = data;
        	}
        },
        error:function (XMLHttpRequest, textStatus, errorThrown){
        	result = null;
        }
    });    
	return result;
}

var obj= new Object();
function ajaxFunc(t_type,t_async,t_url,t_data,t_func,t_dom){		
	$.ajax({
		type:t_type, cache: false, dataType: 'json',
		async:t_async,
		url:t_url,
		data:t_data,
		success:function(data){			
			//alert(data);
			if(data!=null){
				t_func(data,t_dom);
			}else{
				$(t_dom).html("<div class='clear'>没有相关信息！</div>");
			}
		}
	});
}

function getAjaxReturn(t_type,t_async,t_url,t_data,t_func,t_dom){
	var returnObj = new Object();
		$.ajax({
			type:t_type, cache: false, dataType: 'json',
			async:t_async,
			url:t_url,
			data:t_data,
			success:function(data){			
				//alert(data);
				if(data!=null){
					//t_func(data,t_dom);
					returnObj = data.resultData;
					console.log(data.resultData);
				}else{
					$(t_dom).html("<div class='clear'>没有相关信息！</div>");
				}
			}
		});
		return returnObj;
}

function tableSet(tableDom,tableTitle){
	$(tableDom).datagrid({
		width:'100%',
		title : tableTitle,
		nowrap : true,//设置为true，当数据长度超出列宽时将会自动截取
		striped : true,//设置为true将交替显示行背景。
		collapsible : true,//显示可折叠按钮
		loadMsg : '数据装载中......',
		fitColumns:true,//允许表格自动缩放，以适应父容器
		fit:true,
		sortName : 'operation',//当数据表格初始化时以哪一列来排序
		sortOrder : 'asc',//定义排序顺序，可以是'asc'或者'desc'（正序或者倒序）。
		remoteSort : false,
		pagination :true,
		pageSize:15,
		pageList:[10,15,20,25,30,40,50],
		rownumbers : true//行数  
	});
	$(tableDom).datagrid().datagrid('clientPaging');
	var p = $(tableDom).datagrid('getPager'); 
	$(p).pagination({ 
		pageSize:15,
		pageNumber:1,
		beforePageText: '第',//页数文本框前显示的汉字 
		afterPageText: '页    共 {pages} 页', 
		displayMsg: '当前显示 {from} - {to} 条记录   共 {total} 条记录'
	});
}	
function tableSetSortno(tableDom,tableTitle){
	$(tableDom).datagrid({
		width:'100%',
		title : tableTitle,
		nowrap : true,//设置为true，当数据长度超出列宽时将会自动截取
		striped : true,//设置为true将交替显示行背景。
		collapsible : true,//显示可折叠按钮
		loadMsg : '数据装载中......',
		fitColumns:true,//允许表格自动缩放，以适应父容器
		fit:true,
		sortName : 'sortsno',//当数据表格初始化时以哪一列来排序
		sortOrder : 'asc',//定义排序顺序，可以是'asc'或者'desc'（正序或者倒序）。
		remoteSort : false,
		pagination :true,
		pageSize:15,
		pageList:[10,15,20,25,30,40,50],
		rownumbers : true//行数  
	});
	$(tableDom).datagrid().datagrid('clientPaging');
	var p = $(tableDom).datagrid('getPager'); 
	$(p).pagination({ 
		pageSize:15,
		pageNumber:1,
		beforePageText: '第',//页数文本框前显示的汉字 
		afterPageText: '页    共 {pages} 页', 
		displayMsg: '当前显示 {from} - {to} 条记录   共 {total} 条记录'
	});
}

/*(function($){
	function pagerFilter(data){
		if ($.isArray(data)){	// is array
			data = {
				total: data.length,
				rows: data
			}
		}
		var dg = $(this);
		var state = dg.data('datagrid');
		var opts = dg.datagrid('options');
		if (!state.allRows){
			state.allRows = (data.rows);
		}
		var start = (opts.pageNumber-1)*parseInt(opts.pageSize);
		var end = start + parseInt(opts.pageSize);
		data.rows = $.extend(true,[],state.allRows.slice(start, end));
		return data;
	}

	var loadDataMethod = $.fn.datagrid.methods.loadData;
	$.extend($.fn.datagrid.methods, {
		clientPaging: function(jq){
			return jq.each(function(){
				var dg = $(this);
                var state = dg.data('datagrid');
                var opts = state.options;
                opts.loadFilter = pagerFilter;
                var onBeforeLoad = opts.onBeforeLoad;
                opts.onBeforeLoad = function(param){
                    state.allRows = null;
                    return onBeforeLoad.call(this, param);
                }
				dg.datagrid('getPager').pagination({
					onSelectPage:function(pageNum, pageSize){
						opts.pageNumber = pageNum;
						opts.pageSize = pageSize;
						$(this).pagination('refresh',{
							pageNumber:pageNum,
							pageSize:pageSize
						});
						dg.datagrid('loadData',state.allRows);
					}
				});
                $(this).datagrid('loadData', state.data);
                if (opts.url){
                	$(this).datagrid('reload');
                }
			});
		},
        loadData: function(jq, data){
            jq.each(function(){
                $(this).data('datagrid').allRows = null;
            });
            return loadDataMethod.call($.fn.datagrid.methods, jq, data);
        },
        getAllRows: function(jq){
        	return jq.data('datagrid').allRows;
        }
	})
})(jQuery);*/
var grid;
//列表加载数据
function createTable(data,t_dom){
	if (data.status=="OK") {
		$(t_dom).datagrid('loadData',data.data);
	}else{
		$(t_dom).datagrid('loadData', {total:0,rows:[]});
	}	
}

//创建combobox
function createCombobox(data,t_dom){
		$(t_dom).combobox({
			data:data.data
		});	
}

//创建combotree
function createCombotree(data,t_dom){
		$(t_dom).combotree({
			data:data
		});	
}
//创建树
function createTree(t_data,t_dom){
	var setting = {
			data: {
				simpleData: {
					enable: true
				}				
			}
		};
	$.fn.zTree.init($(t_dom), setting, t_data);
}

//确认执行
function confirmop(ajaxFunc,param1,param2,param3,param4,param5,param6){
	$.messager.confirm('确认信息','确定吗?',function(r){
		if(r){
			ajaxFunc(param1,param2,param3,param4,param5,param6);
		}else{
			return;
		}
		
	});	
}
//确认执行
//confirmop(ajaxFunc,"post",false,"roles.updateRoles.do",authObj,dealRolesData,"");
function confirmopSender(sender,target,data,reqmethod,invoketype,callback,t_dom){
	$.messager.confirm('Confirm','确定吗?',function(r){
		if(r){	
			sender(target,data,reqmethod,invoketype,callback,t_dom);

		}else{
			return;
		}
		
	});
	
}
//表单验证
var result;
//验证身份证号
var aCity={11:"北京",12:"天津",13:"河北",14:"山西",15:"内蒙古",21:"辽宁",22:"吉林",23:"黑龙江",31:"上海",32:"江苏",33:"浙江",34:"安徽",35:"福建",36:"江西",37:"山东",41:"河南",42:"湖北",43:"湖南",44:"广东",45:"广西",46:"海南",50:"重庆",51:"四川",52:"贵州",53:"云南",54:"西藏",61:"陕西",62:"甘肃",63:"青海",64:"宁夏",65:"新疆",71:"台湾",81:"香港",82:"澳门",91:"国外"} 

function isCardID(sId){ 
	var iSum=0 ;
	var info="" ;
	if(!/^\d{17}(\d|x)$/i.test(sId)) return false;//"你输入的身份证长度或格式错误"
	sId=sId.replace(/x$/i,"a"); 
	if(aCity[parseInt(sId.substr(0,2))]==null) return false;//"你的身份证地区非法"; 
	sBirthday=sId.substr(6,4)+"-"+Number(sId.substr(10,2))+"-"+Number(sId.substr(12,2)); 
	var d=new Date(sBirthday.replace(/-/g,"/")) ;
	if(sBirthday!=(d.getFullYear()+"-"+ (d.getMonth()+1) + "-" + d.getDate()))return false;// "身份证上的出生日期非法"; 
	for(var i = 17;i>=0;i --) iSum += (Math.pow(2,i) % 11) * parseInt(sId.charAt(17 - i),11) ;
	if(iSum%11!=1) return false;//"你输入的身份证号非法"; 
	return true;//aCity[parseInt(sId.substr(0,2))]+","+sBirthday+","+(sId.substr(16,1)%2?"男":"女") 
} 

//验证日期格式
function checkInputDate(obj){
	result = true;
	var  strDate=obj;
   var re =/^(\d{4})-(\d{2})-(\d{2})$/;
   if(re.test(strDate)){//判断日期格式符合YYYY-MM-DD标准
	   var  dateElement=new  Date(RegExp.$1,parseInt(RegExp.$2,10)-1,RegExp.$3);
	   if(!((dateElement.getFullYear()==parseInt(RegExp.$1))&&((dateElement.getMonth()+1)==parseInt(RegExp.$2,10))&&(dateElement.getDate()==parseInt(RegExp.$3)))){//判断日期逻辑
		   result = false;
	   }
   }else{
	   result = false;
   }
   $('.datebox').find('input').blur(function(event){
	   var event = event || window.event;
	   var targetElem = event.target || event.srcElement;
	   if (!result) {
		   $(targetElem).closest('.datebox').prev().datebox('setValue', ''); 
	   }
   });
   return result;
}
//验证机构id格式，必须是英文（拼音）
function checkOrgId(obj){
	result = false;
	var  strId=obj;
   var re =/^[a-z0-9]+$/;
   if(re.test(strId)){//判断用户输入的orgid是否是小写的英文	   
	   result = true;
   }
   $('#orgIDInput').blur(function(){
	   if (!result) {
		   $('#orgIDInput').val(""); 
	   }
   });
   return result;
}
//input-combobox 性别验证
function checkGender(obj,b) {
	console.log(obj,b);
   var val = $('#userGenderInput').combobox('getText');  //当前combobox的值
   var allData = $('#userGenderInput').combobox("getData");   //获取combobox所有数据
   result = false;      //为false说明输入的值在下拉框数据中不存在
   var count;
   for (var i = 0; i < allData.length; i++) {
       if (val == allData[i].gender) {
           result = true;
           count = allData[i].genderid;
       }
   }
 //失去焦点是验证
   $('#userGenderInput').next('.combo').find('input').blur(function(){
	   if (!result) {
		   $('#userGenderInput').combobox('select',''); 
	   }else{
		   $('#userGenderInput').combobox('select',count);
	   }
   });		  
   return result;  
} 
//input-combobox 添加用户职位验证
function checkPosition(obj) {
   var val = $('#userPositionInput').combobox('getText');  //当前combobox的值
   var allData = $('#userPositionInput').combobox("getData");   //获取combobox所有数据
   result = false;      //为false说明输入的值在下拉框数据中不存在
   var count;
   for (var i = 0; i < allData.length; i++) {
       if (val == allData[i].position) {
           result = true;
           count = allData[i].positionid;
       }
   }
 //失去焦点是验证
   $('#userPositionInput').next('.combo').find('input').blur(function(){
	   if (!result) {
		   $('#userPositionInput').combobox('select',''); 
	   }else{
		   $('#userPositionInput').combobox('select',count);
	   }
   });		  
   return result;  
}
//input-combobox 添加行政职务职位验证
function checkPositionAdmin(obj) {
   var val = $('#positionInp').combobox('getText');  //当前combobox的值
   var allData = $('#positionInp').combobox("getData");   //获取combobox所有数据
   result = false;      //为false说明输入的值在下拉框数据中不存在
   var count;
   for (var i = 0; i < allData.length; i++) {
       if (val == allData[i].position) {
           result = true;
           count = allData[i].positionid;
       }
   }
 //失去焦点是验证
   $('#positionInp').next('.combo').find('input').blur(function(){
	   if (!result) {
		   $('#positionInp').combobox('select',''); 
	   }else{
		   $('#positionInp').combobox('select',count);
	   }
   });		  
   return result;  
}
//input-combobox 添加用户现工作岗位验证
function checkActPosition(obj) {
   var val = $('#userActualPositionInput').combobox('getText');  //当前combobox的值
   var allData = $('#userActualPositionInput').combobox("getData");   //获取combobox所有数据
   result = false;      //为false说明输入的值在下拉框数据中不存在
   var count;
   for (var i = 0; i < allData.length; i++) {
       if (val == allData[i].actualposition) {
           result = true;
           count = allData[i].actualpositionid;
       }
   }
 //失去焦点是验证
   $('#userActualPositionInput').next('.combo').find('input').blur(function(){
	   if (!result) {
		   $('#userActualPositionInput').combobox('select',''); 
	   }else{
		   $('#userActualPositionInput').combobox('select',count);
	   }
   });		  
   return result;  
}
//input-combobox 添加兼职现工作岗位验证
function checkActPositionPart(obj) {
   var val = $('#partActualPosition').combobox('getText');  //当前combobox的值
   var allData = $('#partActualPosition').combobox("getData");   //获取combobox所有数据
   result = false;      //为false说明输入的值在下拉框数据中不存在
   var count;
   for (var i = 0; i < allData.length; i++) {
       if (val == allData[i].actualposition) {
           result = true;
           count = allData[i].actualpositionid;
       }
   }
 //失去焦点是验证
   $('#partActualPosition').next('.combo').find('input').blur(function(){
	   if (!result) {
		   $('#partActualPosition').combobox('select',''); 
	   }else{
		   $('#partActualPosition').combobox('select',count);
	   }
   });		  
   return result;  
}
//input-combobox 健康验证
function checkHealth(obj) {
   var val = $('#userHealthInput').combobox('getText');  //当前combobox的值
   var allData = $('#userHealthInput').combobox("getData");   //获取combobox所有数据
   result = false;      //为false说明输入的值在下拉框数据中不存在
   var count;
   for (var i = 0; i < allData.length; i++) {
       if (val == allData[i].health) {
           result = true;
           count = allData[i].healthid;
       }
   }
 //失去焦点是验证
   $('#userHealthInput').next('.combo').find('input').blur(function(){
	   if (!result) {
		   $('#userHealthInput').combobox('select',''); 
	   }else{
		   $('#userHealthInput').combobox('select',count);
	   }
   });		  
   return result;  
}
//input-combobox 工作状态验证
function checkWorkstatus(obj) {
   var val = $('#userWorkstatusInput').combobox('getText');  //当前combobox的值
   var allData = $('#userWorkstatusInput').combobox("getData");   //获取combobox所有数据
   result = false;      //为false说明输入的值在下拉框数据中不存在
   var count;
   for (var i = 0; i < allData.length; i++) {
       if (val == allData[i].workstatus) {
           result = true;
           count = allData[i].workstatusid;
       }
   }
 //失去焦点是验证
   $('#userWorkstatusInput').next('.combo').find('input').blur(function(){
	   if (!result) {
		   $('#userWorkstatusInput').combobox('select',''); 
	   }else{
		   $('#userWorkstatusInput').combobox('select',count);
	   }
   });		  
   return result;  
}
//input-combobox 证件类型验证
function checkCertype(obj) {
   var val = $('#certypeInput').combobox('getText');  //当前combobox的值
   var allData = $('#certypeInput').combobox("getData");   //获取combobox所有数据
   result = false;      //为false说明输入的值在下拉框数据中不存在
   var count;
   for (var i = 0; i < allData.length; i++) {
       if (val == allData[i].certype) {
           result = true;
           count = allData[i].certypeid;
       }
   }
 //失去焦点是验证
   $('#certypeInput').next('.combo').find('input').blur(function(){
	   if (!result) {
		   $('#certypeInput').combobox('select',''); 
	   }else{
		   $('#certypeInput').combobox('select',count);
	   }
   });		  
   return result;  
}
//input-combobox 减员途径验证
function checkLeavereason(obj) {
   var val = $('#userLeavereasonInput').combobox('getText');  //当前combobox的值
   var allData = $('#userLeavereasonInput').combobox("getData");   //获取combobox所有数据
   result = false;      //为false说明输入的值在下拉框数据中不存在
   var count;
   for (var i = 0; i < allData.length; i++) {
       if (val == allData[i].leavereason) {
           result = true;
           count = allData[i].leavereasonid;
       }
   }
 //失去焦点是验证
   $('#userLeavereasonInput').next('.combo').find('input').blur(function(){
	   if (!result) {
		   $('#userLeavereasonInput').combobox('select',''); 
	   }else{
		   $('#userLeavereasonInput').combobox('select',count);
	   }
   });		  
   return result;  
}
//input-combobox 职务级别验证
function checkPositionlevel(obj) {
   var val = $('#positionlevelInp').combobox('getText');  //当前combobox的值
   var allData = $('#positionlevelInp').combobox("getData");   //获取combobox所有数据
   result = false;      //为false说明输入的值在下拉框数据中不存在
   var count;
   for (var i = 0; i < allData.length; i++) {
       if (val == allData[i].positionlevel) {
           result = true;
           count = allData[i].positionlevelid;
       }
   }
 //失去焦点是验证
   $('#positionlevelInp').next('.combo').find('input').blur(function(){
	   if (!result) {
		   $('#positionlevelInp').combobox('select',''); 
	   }else{
		   $('#positionlevelInp').combobox('select',count); 
	   }
   });		  
   return result;  
}
//input-combobox 职务类型验证
function checkPositiontype(obj) {
   var val = $('#positiontypeInp').combobox('getText');  //当前combobox的值
   var allData = $('#positiontypeInp').combobox("getData");   //获取combobox所有数据
   result = false;      //为false说明输入的值在下拉框数据中不存在
   var count;
   for (var i = 0; i < allData.length; i++) {
       if (val == allData[i].positiontype) {
           result = true;
           count = allData[i].positiontypeid;
       }
   }
 //失去焦点是验证
   $('#positiontypeInp').next('.combo').find('input').blur(function(){
	   if (!result) {
		   $('#positiontypeInp').combobox('select',''); 
	   }else{
		   $('#positiontypeInp').combobox('select',count);
	   }
   });		  
   return result;  
}
//input-combotree 兼职机构验证
function checkPartOrg(obj) {
   var t = $('#partOrg').combotree('tree');	// get the tree object
   var val = $('#partOrg').combotree('getText');
   var allData = t.tree("getChildren");   //获取combotree所有数据
   result = false;      //为false说明输入的值在下拉框数据中不存在
   var orgidStr;
   for (var i = 0; i < allData.length; i++) {
       if (val == allData[i].text) {
           result = true;
           orgidStr = allData[i].id;
       }
   }
 //失去焦点是验证
   $('#partOrg').next('.combo').find('input').blur(function(){
	   if (!result) {
		   $('#partOrg').combotree('setValue','');
	   }else{
		   $('#partOrg').combotree('setValue',orgidStr);
	   }
   });		  
   return result;  
}
//input-combotree 修改人员机构验证
function checkModOrg(obj) {
   var t = $('#userOrgInput').combotree('tree');	// get the tree object
   var val = $('#userOrgInput').combotree('getText');
   var allData = t.tree("getChildren");   //获取combotree所有数据
   result = false;      //为false说明输入的值在下拉框数据中不存在
   var orgidStr;
   for (var i = 0; i < allData.length; i++) {
       if (val == allData[i].text) {
           result = true;
           orgidStr = allData[i].id;
       }
   }
 //失去焦点是验证
   $('#userOrgInput').next('.combo').find('input').blur(function(){
	   if (!result) {
		   $('#userOrgInput').combotree('setValue','');
	   }else{
		   $('#userOrgInput').combotree('setValue',orgidStr);
	   }
   });		  
   return result;  
}
//input-combobox 添加机构机构级别验证
/*function checkOrgLevel(obj) {
   var val = $('#orgLevelInput').combobox('getText');  //当前combobox的值
   var allData = $('#orgLevelInput').combobox("getData");   //获取combobox所有数据
   result = false;      //为false说明输入的值在下拉框数据中不存在
   for (var i = 0; i < allData.length; i++) {
       if (val == allData[i].text) {
           result = true;
       }
   }
 //失去焦点是验证
   $('#orgLevelInput').next('.combo').find('input').blur(function(){
	   if (!result) {
		   $('#orgLevelInput').combobox('select',''); 
	   }
   });		  
   return result;  
}*/
//input-combobox 修改机构机构级别验证
function checkOrgLevelMod(obj) {
   var val = $('#orgLevelModInput').combobox('getText');  //当前combobox的值
   var allData = $('#orgLevelModInput').combobox("getData");   //获取combobox所有数据
   result = false;      //为false说明输入的值在下拉框数据中不存在
   var count;
   for (var i = 0; i < allData.length; i++) {
       if (val == allData[i].orglevel) {
           result = true;
           count = allData[i].orglevelid;
       }
   }
 //失去焦点是验证
   $('#orgLevelModInput').next('.combo').find('input').blur(function(){
	   if (!result) {
		   $('#orgLevelModInput').combobox('select',''); 
	   }else{
		   $('#orgLevelModInput').combobox('select',count);
	   }
   });		  
   return result;  
}
//input-combobox 添加机构机构是否虚拟验证
function checkorgIsvirtual(obj) {
   var val = $('#orgIsvirtualInput').combobox('getText');  //当前combobox的值
   var allData = $('#orgIsvirtualInput').combobox("getData");   //获取combobox所有数据
   result = false;      //为false说明输入的值在下拉框数据中不存在
   for (var i = 0; i < allData.length; i++) {
       if (val == allData[i].text) {
           result = true;
       }
   }
 //失去焦点是验证
   $('#orgIsvirtualInput').next('.combo').find('input').blur(function(){
	   if (!result) {
		   $('#orgIsvirtualInput').combobox('select',''); 
	   }
   });		  
   return result;  
}
//input-combobox 添加机构机构是否虚拟验证
function checkorgIsvirtualMod(obj) {
   var val = $('#orgIsvirtualModInput').combobox('getText');  //当前combobox的值
   var allData = $('#orgIsvirtualModInput').combobox("getData");   //获取combobox所有数据
   result = false;      //为false说明输入的值在下拉框数据中不存在
   for (var i = 0; i < allData.length; i++) {
       if (val == allData[i].text) {
           result = true;
       }
   }
 //失去焦点是验证
   $('#orgIsvirtualModInput').next('.combo').find('input').blur(function(){
	   if (!result) {
		   $('#orgIsvirtualModInput').combobox('select',''); 
	   }
   });		  
   return result;  
}
//input-combobox 添加修改人员民族验证
function checkMinzu(obj) {
   var val = $('#userMinzuInput').combobox('getText');  //当前combobox的值
   var allData = $('#userMinzuInput').combobox("getData");   //获取combobox所有数据
   result = false;      //为false说明输入的值在下拉框数据中不存在
   var count;
   for (var i = 0; i < allData.length; i++) {
       if (val == allData[i].minzu) {
           result = true;
           count = allData[i].minzuid;
       }
   }
 //失去焦点是验证
   $('#userMinzuInput').next('.combo').find('input').blur(function(){
	   if (!result) {
		   $('#userMinzuInput').combobox('select',''); 
	   }else{
		   $('#userMinzuInput').combobox('select',count);
	   }
   });		  
   return result;  
}
var cardIDValue;
$.extend($.fn.validatebox.defaults.rules, {   
    idcared: {   
        validator: function(value,param){  
    		var flag= isCardID(value);  
    		if(flag){
    			cardIDValue = value;
    		}
            return flag==true?true:false;  
        },   
        message: '不是有效的身份证号码'  
    },
    inputdate:{
    	validator: function(value,param){  
    		var flag= checkInputDate(value);
            return flag==true?true:false;  
        },   
        message: '日期格式不正确'
    } ,   
  //性别验证
    genderInputcombobox:{
    	validator: function(value){  
    		console.log(this.target);
    		var flag= checkGender(value);    		
            return flag==true?true:false;  
        },   
        message: '请输入正确性别'
    },
    //添加用户职位验证
    positionInputcombobox:{
    	validator: function(value,param){  
    		var flag= checkPosition(value);    		
            return flag==true?true:false;  
        },   
        message: '请输入正确职位'
    },
  //添加行政职务职位验证
    positionAdmincombobox:{
    	validator: function(value,param){  
    		var flag= checkPositionAdmin(value);    		
            return flag==true?true:false;  
        },   
        message: '请输入正确职位'
    },    
  //添加用户现工作岗位验证
    actPositionInputcombobox:{
    	validator: function(value,param){  
    		var flag= checkActPosition(value);    		
            return flag==true?true:false;  
        },   
        message: '请输入正确现工作岗位'
    },
  //添加兼职现工作岗位验证
    actPositionPartcombobox:{
    	validator: function(value,param){  
    		var flag= checkActPositionPart(value);    		
            return flag==true?true:false;  
        },   
        message: '请输入正确现工作岗位'
    },    
  //健康验证
    healthInputcombobox:{
    	validator: function(value,param){  
    		var flag= checkHealth(value);    		
            return flag==true?true:false;  
        },   
        message: '请输入正确健康'
    },
  //工作状态验证
    workstatusInputcombobox:{
    	validator: function(value,param){  
    		var flag= checkWorkstatus(value);    		
            return flag==true?true:false;  
        },   
        message: '请输入正确工作状态'
    },
  //证件类型
    certypeInputcombobox:{
    	validator: function(value,param){  
    		var flag= checkCertype(value);    		
            return flag==true?true:false;  
        },   
        message: '请输入正确证件类型'
    },
  //减员途径验证
    leavereasonInputcombobox:{
    	validator: function(value,param){  
    		var flag= checkLeavereason(value);    		
            return flag==true?true:false;  
        },   
        message: '请输入正确减员途径'
    },
  //职务级别验证
    positionLevInputcombobox:{
    	validator: function(value,param){  
    		var flag= checkPositionlevel(value);    		
            return flag==true?true:false;  
        },   
        message: '请输入正确职务级别'
    },
  //职务类型验证
    positionTypInputcombobox:{
    	validator: function(value,param){  
    		var flag= checkPositiontype(value);    		
            return flag==true?true:false;  
        },   
        message: '请输入正确职务类型'
    },
  //兼职机构验证
    partOrgCombotree:{
    	validator: function(value,param){  
    		var flag= checkPartOrg(value);    		
            return flag==true?true:false;  
        },   
        message: '请输入正确兼职机构'
    },
  //修改机构验证
    modOrgCombotree:{
    	validator: function(value,param){  
    		var flag= checkModOrg(value);    		
            return flag==true?true:false;  
        },   
        message: '请输入正确部门'
    },    
  //添加机构机构级别验证
    orgLevelcombobox:{
    	validator: function(value,param){  
    		var flag= checkOrgLevel(value);    		
            return flag==true?true:false;  
        },   
        message: '请输入正确机构级别'
    },
  //修改机构机构级别验证
    orgLevelModcombobox:{
    	validator: function(value,param){  
    		var flag= checkOrgLevelMod(value);    		
            return flag==true?true:false;  
        },   
        message: '请输入正确机构级别'
    },    
  //添加机构机构是否虚拟验证
    orgIsvirtualcombobox:{
    	validator: function(value,param){  
    		var flag= checkorgIsvirtual(value);    		
            return flag==true?true:false;  
        },   
        message: '请输入机构是否有编制'
    },
  //修改机构机构是否虚拟验证
    orgIsvirtualModcombobox:{
    	validator: function(value,param){  
    		var flag= checkorgIsvirtualMod(value);    		
            return flag==true?true:false;  
        },   
        message: '请输入机构是否有编制'
    },    
  //机构id为小写英文验证
    orgidtextbox:{
    	validator: function(value,param){  
    		var flag= checkOrgId(value);    		
            return flag==true?true:false;  
        },   
        message: '机构ID应为小写英文或小写英文加数字'
    },
  //人员添加修改民族验证
    minzuInputcombobox:{
    	validator: function(value,param){  
    		var flag= checkMinzu(value);    		
            return flag==true?true:false;  
        },   
        message: '请输入正确的民族'
    } 
});

//数组indexof方法
Array.prototype.indexOf = function(elt)
{
    var len = this.length >>> 0;

    var from = Number(arguments[1]) || 0;
    from = (from < 0)
        ? Math.ceil(from)
        : Math.floor(from);
    if (from < 0)
        from += len;

    for (; from < len; from++)
    {
        if (from in this &&
            this[from] === elt)
            return from;
    }
    return -1;
};

//数组去重
Array.prototype.unique = function(){
	var n = [];
	for (var i = 0; i < this.length; i++){
		if (n.indexOf(this[i]) == -1){
			n.push(this[i]);
		}/* else{
			alert("unique one");
		} */
	}
	return n;
}
//datagrid中按照姓名部门的汉字首字母排序
function sortWord(a,b){
	  /* var valuePid = ($('#tg').datagrid('getData').rows)[0].parentorgid; 
	  var valueOrgname = ($('#tg').datagrid('getData').rows)[0].orgname; 
	  if(valuePid != obj["parentorgid"]){
		  if((a != valueOrgname)&&(b != valueOrgname)){
  		   if(a.localeCompare(b) > 0){
      		   return 1;
      	   }else{
      		   return -1;
      	   } 
  	   }
	  }else{ */
  		   if(a.localeCompare(b) > 0){
      		   return 1;
      	   }else{
      		   return -1;
      	   } 
	  /* } */
}
//datagrid中数字排序
function sortNumber(a,b){
	if(a - b > 0){
		return 1;
	}else{
		return -1;
	}
}
//左右input依赖组件(insertRow增加一项  delRow删除一项  dependentFunc左右联动)
//batch页面insertRow
function insertRow(fromDom,toDom){
	var html = "";		
	$(toDom).append($(fromDom).html());
	$(toDom).find('.selectDom:last').after("<div class='cc2Dom' style='float:left;'><input class='easyui-datebox dataInput' style='width:200px;' /></div>");
	$.parser.parse($(toDom).find('.cc2Dom:last'));	
	if($.browser.version=='8.0'){
		$.parser.parse($(toDom).find('.selectContent:last'));
	}
	$(toDom).find('.selectDom:last').click();			
	$(toDom).find('.selectDom:last').find('.combo:last').remove();
	$(toDom).find('.selectDom:last').find("option").eq(3).attr("selected","selected");
	$(toDom).find('.cc3Dom:last').find('.combo:last').remove();
	$(toDom).find('.selectDom:last').find("option").eq(5).attr("selected","selected");
	$(toDom).find('.cc4Dom:last').find('.combo:last').remove();
}
//query页面insertQueryRow
function insertQueryRow(fromDom,toDom){
	$(toDom).append($(fromDom).html());
	$(toDom).find('.selectDom:last').after("<div class='cc2Dom' style='float:left;display:none;'>从<input class='easyui-datebox dataInput' style='width:90px;' />到<input class='easyui-datebox dataInput' style='width:90px;' /></div>");
	$.parser.parse($(toDom).find('.cc2Dom:last'));	
	if($.browser.version=='8.0'){
		$.parser.parse($(toDom).find('.selectContent:last'));
	}			
	$(toDom).find('.selectDom:last').click();			
	$(toDom).find('.selectDom:last').find('.combo:last').remove();
	$(toDom).find('.selectDom:last').find("option").eq(9).attr("selected","selected");
	$(toDom).find('.cc3Dom:last').find('.combo:last').remove();
	$(toDom).find('.selectDom:last').find("option").eq(11).attr("selected","selected");
	$(toDom).find('.cc4Dom:last').find('.combo:last').remove();
}
function delRow(event){
	var event = event || window.event;
	var targetElem = event.target || event.srcElement;
	var html = "";
	//console.log($(targetElem));
	$(targetElem).closest('.selectContent').remove();
}
//左右两个选择项联动
//batch页面dependentFunc
   function dependentFunc(event){	
	    var event = event || window.event;
		var targetElem = event.target || event.srcElement;
		//console.log($(targetElem).find('.selectBox'));
	   ($(targetElem).closest('.selectContent').find('.selectBox')).combobox({
		   //record
		   onSelect:function(record){
					//console.log($(this));
					console.log($(this).combobox('getValue')); 
					selectString = $(this).combobox('getValue');
					selectConElem = $(this).closest($('.selectContent'));
					if((selectString == "reachtime")||(selectString == "beginworktime")||(selectString == "leavetime")||(selectString == "birthday")){
						selectConElem.find($(".cc3Dom")).hide();
						selectConElem.find($(".cc2Dom")).show();
						selectConElem.find($(".cc4Dom")).hide();
						selectConElem.find($(".cc5Dom")).hide();
					}else if(selectString == "leavereasonid"){
						selectConElem.find($(".cc2Dom")).hide();
						selectConElem.find($(".cc3Dom")).show();
						selectConElem.find($(".cc4Dom")).hide();
						selectConElem.find($(".cc5Dom")).hide();
						selectConElem.find($('.boxInput')).combobox({
						    valueField:'leavereasonid',
						    textField:'leavereason'
						});
						ajaxFunc("get",false,"basic.list.do","tablename=gg_leavereason",createCombobox,selectConElem.find($('.boxInput')));
					}else if(selectString == "healthid"){
						selectConElem.find($(".cc2Dom")).hide();
						selectConElem.find($(".cc3Dom")).show();
						selectConElem.find($(".cc4Dom")).hide();
						selectConElem.find($(".cc5Dom")).hide();
						selectConElem.find($('.boxInput')).combobox({
						    valueField:'healthid',
						    textField:'health'
						});
						ajaxFunc("get",false,"basic.list.do","tablename=gg_health",createCombobox,selectConElem.find($('.boxInput')));
					}else if(selectString == "genderid"){
						selectConElem.find($(".cc2Dom")).hide();
						selectConElem.find($(".cc3Dom")).show();
						selectConElem.find($(".cc4Dom")).hide();
						selectConElem.find($(".cc5Dom")).hide();
						selectConElem.find($('.boxInput')).combobox({
						    valueField:'genderid',
						    textField:'gender'
						});
						ajaxFunc("get",false,"basic.list.do","tablename=gg_gender",createCombobox,selectConElem.find($('.boxInput')));
					}else if(selectString == "positionid"){
						selectConElem.find($(".cc2Dom")).hide();
						selectConElem.find($(".cc3Dom")).show();
						selectConElem.find($(".cc4Dom")).hide();
						selectConElem.find($(".cc5Dom")).hide();
						selectConElem.find($('.boxInput')).combobox({
						    valueField:'positionid',
						    textField:'position'
						});
						ajaxFunc("get",false,"basic.list.do","tablename=gg_position",createCombobox,selectConElem.find($('.boxInput')));
					}else if(selectString == "actualpositionid"){
						selectConElem.find($(".cc2Dom")).hide();
						selectConElem.find($(".cc3Dom")).show();
						selectConElem.find($(".cc4Dom")).hide();
						selectConElem.find($(".cc5Dom")).hide();
						selectConElem.find($('.boxInput')).combobox({
						    valueField:'actualpositionid',
						    textField:'actualposition'
						});
						ajaxFunc("get",false,"basic.list.do","tablename=gg_actualposition",createCombobox,selectConElem.find($('.boxInput')));
					}else if(selectString == "workstatusid"){
						selectConElem.find($(".cc2Dom")).hide();
						selectConElem.find($(".cc3Dom")).show();
						selectConElem.find($(".cc4Dom")).hide();
						selectConElem.find($(".cc5Dom")).hide();
						selectConElem.find($('.boxInput')).combobox({
						    valueField:'workstatusid',
						    textField:'workstatus'
						});
						if(queryStatus == undefined){
							ajaxFunc("get",false,"basic.list.do","tablename=gg_workstatus",createCombobox,selectConElem.find($('.boxInput')));
						}else{
							var isloginObj = new Object();
							if(queryStatus[0] == 0){
								isloginObj["islogin"] = 0;
							}else{
								isloginObj["islogin"] = 1;
							}
							isloginObj["tablename"] = "gg_workstatus";
							ajaxFunc("get",false,"basic.list.do",isloginObj,createCombobox,selectConElem.find($('.boxInput')));
						}
					}else if(selectString == "orgid"){
						selectConElem.find($(".cc2Dom")).hide();
						selectConElem.find($(".cc3Dom")).hide();
						selectConElem.find($(".cc4Dom")).show();
						selectConElem.find($(".cc5Dom")).hide();
						ajaxFunc("get",false,"org.tree.do","",createCombotree,selectConElem.find($(".treeInput")));
					}else if((selectString == "username")||(selectString == "identify")){
						selectConElem.find($(".cc3Dom")).hide();
						selectConElem.find($(".cc2Dom")).hide();
						selectConElem.find($(".cc4Dom")).hide();
						selectConElem.find($(".cc5Dom")).show();
					}  
				}
		    });
    }
